package com.xbongbong.pro.i18n;

import com.xbongbong.paas.toolbox.util.I18nUtil;
import com.xbongbong.paas.toolbox.util.StringUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;

/**
 * 自定义LocaleResolver
 *
 * @author kaka
 * @version v1.0
 * @date 2020/5/8 14:05
 * @since v1.0
 */
@Configuration
public class XbbLocaleResolver implements LocaleResolver {

    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        String lang = request.getParameter("lang");
        return I18nUtil.getLocale(lang);
    }


    @Override
    public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) {

    }
}
